package com.xauto.pioneer.appuser.adapter;

import android.app.Activity;
import android.view.View;
import android.widget.TextView;

import com.xauto.pioneer.appuser.R;
import com.xauto.pioneer.appuser.model.CarRefuelInfo;

/**
 * Created by Lemon on 2015/12/11.
 * Desc:加油列表 适配器
 */
public class RefuelAdapter extends AbsAdapter<CarRefuelInfo> {

    public RefuelAdapter(Activity context, int layout) {
        super(context, layout);
    }

    @Override
    public ViewHolder<CarRefuelInfo> getHolder() {
        return new TemplateViewHolder();
    }


    private class TemplateViewHolder implements ViewHolder<CarRefuelInfo> {

        private TextView tvOrderNo;
        private TextView tvOrderStatus;
        private TextView tvRefuelName;
        private TextView tvRefuelDate;
        private TextView tvRefuelMoney;

        @Override
        public void initViews(View v, int position) {
            tvOrderNo = (TextView) v.findViewById(R.id.tvOrderNo);
            tvOrderStatus = (TextView) v.findViewById(R.id.tvOrderStatus);
            tvRefuelName = (TextView) v.findViewById(R.id.tvRefuelName);
            tvRefuelDate = (TextView) v.findViewById(R.id.tvRefuelDate);
            tvRefuelMoney = (TextView) v.findViewById(R.id.tvRefuelMoney);
        }

        @Override
        public void updateData(CarRefuelInfo carRefuelInfo, int position) {
            tvOrderNo.setText(context.getString(R.string.order_no,carRefuelInfo.car_order_no));
            tvOrderStatus.setText(carRefuelInfo.car_refuel_status_name);
            switch (carRefuelInfo.car_refuel_status_style_color){
                case "0":
                    tvOrderStatus.setTextColor(context.getResources().getColor(R.color.black));
                    break;
                case "1":
                    tvOrderStatus.setTextColor(context.getResources().getColor(R.color.red));
                    break;
                case "2":
                    tvOrderStatus.setTextColor(context.getResources().getColor(R.color.grey));
                    break;
            }
            tvRefuelName.setText("");
           // tvRefuelName.setText(carRefuelInfo.plate_no+"/"+carRefuelInfo.car_refuel_status_name);
            tvRefuelDate.setText("日期:"+carRefuelInfo.time);
            tvRefuelMoney.setText("费用:"+carRefuelInfo.car_refuel_amount_format);
        }

        @Override
        public void doOthers(CarRefuelInfo carRefuelInfo, int position) {

        }
    }
}
